require("../css/conInfo.less");

const utils = require("../utils/utils.js");

const axios = require("../utils/axiosUtil.js");

const baseUrl = require("../utils/baseUrl.js");

window.onload=function(){
    let data = utils.forch(location.search);
    let ship = [];
    axios.get("/api/train/courseDetail?id="+data.id).then(function(res){
        let date = res.data.data;
        ship = date.fragments;
        console.log(date);
        document.querySelector(".course-img img").src = baseUrl + date.imgurl;
        document.querySelector(".course-title h1").innerText = date.name;
        document.querySelector(".desc").innerText = date.desc;
        document.querySelector(".calorie").innerText = date.calorie;
        document.querySelector(".timer").innerText = date.time;
        
    })
    
    let backs = document.querySelector(".back");
    backs.addEventListener("click",function(){
        location.href = "../course.html"
    })

   let btn = document.querySelector(".btn");
    let startI = document.querySelector(".start i");


    btn.addEventListener("click",function(){
        location.href = "../play.html"
        // console.log(ship);
        sessionStorage.setItem("ship",JSON.stringify(ship));
        
    })
    startI.addEventListener("click",function(){
        btn.click();
    })













    
}